<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
            "http://www.w3.org/TR/html4/strict.dtd">

<jsp:directive.page errorPage="/WEB-INF/dmv/ErrorPage.jsp"/>
<jsp:directive.page import="org.twndmv.dto.*"/>
<jsp:directive.page import="java.text.SimpleDateFormat"/>
<html>
    <title>Display Driver</title>
    <body>

        <jsp:scriptlet>
            PersonDTO person = (PersonDTO)request.getAttribute("result");
            PhysicalDetailsDTO details = person.getPhysicalDetails();
            SimpleDateFormat formater = new SimpleDateFormat("MM/dd/yyyy");
        </jsp:scriptlet>

        Id: <%= person.getId() %><p/>
        First Name: <%=person.getFirstName()%><p/>
        Middle Name: <%=person.getMiddleName()%><p/>
        Last Name: <%=person.getLastName()%><p/>
        
        Height: <%= details.getHeight() %><p/>
        Weight: <%= details.getWeight() %><p/>
        Hair Color: <%= details.getHairColor() %><p/>
        Eye Color: <%= details.getEyeColor() %><p/>
        Gender: <%= details.getSEX().name() %><p/>
        DOB: <%= formater.format(details.getDob()) %><p/>
        
        Residences:
        <table> 
        <tr><th>Street</th><th>City</th><th>State</th><th>Zip Code</th><th>Move In</th><th>Move Out</th></tr>
        <tbody>
        <jsp:scriptlet>
            
                for(Object o: person.getResidences()) {
                    ResidenceDTO house = (ResidenceDTO)o; 
            </jsp:scriptlet>
                <tr><td><%= house.getStreetNo() + " " + house.getStreetName() %></td>
                <td><%= house.getCity() %></td><td><%= house.getState() %></td>
                <td><%= house.getZipCode() %></td><td><%= formater.format(house.getMoveIn()) %></td><td><%= (house.getMoveOut() != null) ? formater.format(house.getMoveOut()) : "Current Residence" %></td></tr>
            <jsp:scriptlet>
                }
            </jsp:scriptlet>
            </tbody>
        </table>

        <p/><a href="<%=request.getContextPath()%>/index.jsp">Go to Main Page</a>
    </body>
</html>